<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>3986：Tree and Sets</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">Tree and Sets</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">Tree and Sets</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                Tree and Sets                </h1>
                <p>时间限制：20s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：256MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div>有一棵n个结点的树，每条边有个长度leni (1&le;leni&le;10000)。</div>
<div>有q个点集，每个点集给定两个整数u,d (1&le;u&le;n,1&le;d&le;109)，表示所有与u的距离不超过d的点（包括u）在这个点集中。</div>
<div>两个点之间的距离为它们之间的最短路径的长度。</div>
<div></div>
<div>要求构造一个DAG（有向无环图），满足：</div>
<div>1、这个DAG至少有n+q个点，至多有1200000(1.2&times;106)个点和2400000(2.4&times;106)条边</div>
<div>2、对于每一条边u&rarr;v，u&gt;n 且 u&ne;v</div>
<div>3、对于第i (1&le;i&le;q)个点集的每一个点x，第n+i个点到第x个点都有且仅有一条路径</div>
<div>4、对于不在第i (1&le;i&le;q)个点集的每一个点x，第n+i个点到第x个点都不存在路径</div>
<div></div>
<div>由于一些奇怪的原因，树上可能多了若干条边，但是这些边覆盖的树链不会重合，且不会存在自环。（即这棵树是仙人掌）</div>
<div></div>
<p></p></p><hr/><h3>输入格式</h3><p><div>第一行三个整数n,m,q，其中m表示这棵仙人掌上一共有m条边。</div>
<div>接下来m行，每行三个整数u,v,len，表示u和v之间有一条长度为len的无向边。</div>
<div>接下来q行，每行两个整数u,d，第i行表示第i个点集。</div>
<div></div>
<p></p></p><hr/><h3>输出格式</h3><p><div>第一行两个整数V,E，表示你构造的DAG的点数和边数。</div>
<div>接下来E行，每行两个整数u,v，表示u到v有一条有向边。</div>
<div></div>
<div>！！！请注意输出文件的大小，不能超过32MB，否则会显示TLE！！！</div>
<div></div>
<p></p></p><hr/><h3>样例输入</h3><pre>10 9 5
2 1 9553
3 2 8499
4 3 5171
5 1 7123
6 3 1904
7 5 5526
8 7 5853
9 6 6635
10 8 7858
6 4981
7 14400
3 21290
4 9451
10 16609</pre><hr/><h3>样例输出</h3><pre>15 19
11 6
11 3
12 7
12 5
12 1
12 8
12 10
13 3
13 6
13 9
13 4
13 2
13 1
14 4
14 3
14 6
15 10
15 8
15 7</pre><hr/><h3>提示</h3><p><p>N&lt;=10000,N-1&lt;=m&lt;=2*N-2,Q&lt;=10000</p>
<p>尚无SPJ，请不要提交!</p>
<p></p></p><hr/><h3>题目来源</h3><p>2015年集训队互测</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=3986" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=3986" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>